import React from 'react'
import { Form, Input } from 'antd';
import PropTypes from 'prop-types'

class AddRole extends React.Component {

    // 声明父组件传递过来的函数
    static propTypes = {
        setForm: PropTypes.func.isRequired
    }

    // 将自身的值通过函数传递给父组件
    UNSAFE_componentWillMount(){
        this.props.setForm(this.props.form)
    }

  render() {
    const { getFieldDecorator } = this.props.form;
    return (
      <Form onSubmit={this.handleSubmit}>
        <Form.Item>
          {getFieldDecorator('roleName', {
            rules: [{ required: true, message: '角色名称不能为空' }],
          })(
            <Input
              placeholder="请输入角色名称"
            />,
          )}
        </Form.Item>
      </Form>
    );
  }
}

const AddRoleForm = Form.create()(AddRole);
export default AddRoleForm